<?php

namespace common\models\DAO;

use Yii;

/**
 * This is the model class for table "{{%ad_position}}".
 *
 * @property integer $id
 * @property string $name
 * @property string $title
 * @property string $remark
 * @property integer $status
 * @property string $createTime
 */
class AdPosition extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%ad_position}}';
    }

    
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['status', 'createTime'], 'integer'],
            [['name', 'title'], 'required'],
            [['name'], 'string', 'max' => 30],
            [['title'], 'string', 'max' => 100],
            [['name'], 'unique'],
        ];
    }


    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => '主键id',
            'name' => '标示',
            'title' => '标题',
            'remark' => '备注',
            'status' => '状态',//0:不可用；1:可用
            'createTime' => '创建时间',
        ];
    }


    public function scenarios()
    {
        return [
            'default' => [],
            'add' => ['name', 'title', 'remark', 'status'],
            'edit' => ['name', 'title', 'remark', 'status'],
        ];
    }

    public function beforeSave($insert)
    {
        if($insert)
            $this->createTime = time();

        return parent::beforeSave($insert); // TODO: Change the autogenerated stub
    }
}
